package main

import "fmt"

func main() {
	//var a[]int
	//if a == nil {
	//	fmt.Println("yes")
	//}else {
	//	fmt.Println("no")
	//}
	//init1()
	//init2()
	test1()
}

func init1() {
	a := [5]int{1, 2, 3, 4, 5} //声明数组
	var b []int                //声明切片
	b = a[1:4]                 //切片初始化 b = a[start:end-1]
	fmt.Println(b)
}

func init2() {
	a := []int{6, 7, 8}
	fmt.Println(a[0])
}

//切片常用的截取
func test1() {
	a := [5]int{1, 2, 3, 4, 5}
	var b []int
	b = a[1:]
	fmt.Println(b)
	c := a[:5]
	fmt.Println(c)
	d := a[:]
	fmt.Println(d)
}
